package com.jj.service.impl;

import com.jj.dto.ProductTypeWithProductsDTO;
import com.jj.entity.ProductTypes;
import com.jj.mapper.ProductTypesMapper;
import com.jj.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ProductTypeServiceImpl implements ProductTypeService {
    @Autowired
    private ProductTypesMapper productTypesMapper;

    @Override
    public ProductTypes selectById(Integer typeId) {
        return productTypesMapper.selectById(typeId);
    }

    @Override
    public List<ProductTypes> selectAll() {
        return productTypesMapper.selectAll();
    }

    @Override
    @Transactional
    public int insert(ProductTypes productType) {
        return productTypesMapper.insert(productType);
    }

    @Override
    @Transactional
    public int update(ProductTypes productType) {
        return productTypesMapper.update(productType);
    }

    @Override
    @Transactional
    public int deleteById(Integer typeId) {
        return productTypesMapper.deleteById(typeId);
    }

    @Override
    public ProductTypes selectByTypeName(String typeName) {
        return productTypesMapper.selectByTypeName(typeName);
    }

    @Override
    public ProductTypeWithProductsDTO selectTypeWithProducts(Integer typeId) {
        return productTypesMapper.selectTypeWithProducts(typeId);
    }
}
